package com.codez.gznx.excel;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

@SuppressWarnings("rawtypes")
public class Utils {
	
	public static Boolean isEmpty(String str){
		return str == null || str.trim().length() == 0;
	}
	public static Boolean isNotEmpty(String str){
		return ! isEmpty(str);
	}
	
	public static boolean isEmpty(Object obj) {
		if (obj == null) {
			return true;
		}
		if (obj.getClass().isArray()) {
			return Array.getLength(obj) == 0;
		}
		if (obj instanceof CharSequence) {
			return ((CharSequence) obj).length() == 0;
		}
		if (obj instanceof Collection) {
			return ((Collection) obj).isEmpty();
		}
		if (obj instanceof Map) {
			return ((Map) obj).isEmpty();
		}
		return false;
	}
	
	public static Boolean isNotEmpty(Object object){
		return !isEmpty(object);
	}
	
	public static Boolean hasAnyEmpty(Object... objs){
		for (Object object : objs) {
			if(object == null || (object instanceof String && object.toString().trim().length() == 0))
				return Boolean.TRUE;
		}
		return Boolean.FALSE;
	}
	
}
